package edu.wong.pro.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import edu.wong.pro.iservice.IPicture;

public class PictureAction extends ActionSupport{
	private IPicture iPicture;

	//获取图片集
	public void getPictureShow() throws IOException{
		HttpServletResponse response = (HttpServletResponse) ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter writer = response.getWriter();
		writer.print(iPicture.getPictureShow());
		writer.flush();writer.close();	
	}
	
	//通过psid获取当前的图片
	public void getPictureByPsid() throws IOException{
		HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();
		String psid = request.getParameter("psid");
		HttpServletResponse response = (HttpServletResponse) ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter writer = response.getWriter();
		writer.print(iPicture.getPictureByPsid(psid));
		writer.flush();writer.close();	
	}
	
	//通过psid获取当前的图片集信息
		public void getPSByID() throws IOException{
			HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();
			String psid = request.getParameter("psid");
			HttpServletResponse response = (HttpServletResponse) ServletActionContext.getResponse();
			response.setCharacterEncoding("utf-8");
			PrintWriter writer = response.getWriter();
			writer.print(iPicture.getPictureShowByID(psid));
			writer.flush();writer.close();	
		}
	
	public IPicture getiPicture() {
		return iPicture;
	}

	public void setiPicture(IPicture iPicture) {
		this.iPicture = iPicture;
	}
	
}
